import React, { createRef } from 'react';

export default class MyInput extends React.Component {

  inp = createRef(null);

  componentDidMount () {
    this.inp.current.value = this.props.defaultValue;
  }

  onChange (e) {
    this.props.onChange(e.target.value);
  }

  render () {
    return (
      <div className="my-input">
        { this.props.prefix }
        <input
          ref={ this.inp }
          // value={ this.props.value }
          onChange={ this.onChange.bind(this) }
        />
        { this.props.suffix }
      </div>
    );
  }

}
